﻿using LdtJudge.DataEngine.CallInterface.CommHelp;
using LdtJudge.DataEngine.Model.DataModel.DataParseStorage;
using System;
using System.Collections.Generic;
using System.Text;

namespace LdtJudge.DataEngine.Data.DataParseStorage
{
    /// <summary>
    /// 结构数据存储表的数据层
    /// </summary>
    public class DAL_An_jiegoushujucunchu
    {
        //private IFreeSql FreeSql = FreeSQLHelp.GetFreeSQL("LdtAnalysisSource");
        private IFreeSql FreeSql = FreeSQLHelp.GetFreeSQL("Ldt_DataParseStorage");

        /// <summary>
        /// 添加结构数据存储数据
        /// </summary>
        /// <param name="model">结构数据存储模型</param>
        /// <returns></returns>
        public int Insert(An_jiegoushujucunchu model)
        {
            return FreeSql.Insert<An_jiegoushujucunchu>(model).ExecuteAffrows();
        }

        /// <summary>
        /// 更新结构数据存储
        /// </summary>
        /// <param name="model">结构数据存储模型</param>
        /// <returns></returns>
        public int Update(An_jiegoushujucunchu model)
        {
            return FreeSql.Update<An_jiegoushujucunchu>(model).SetSourceIgnore(model, col => col == null).ExecuteAffrows();
        }

        /// <summary>
        /// 根据数据id和数据类型查询结构数据
        /// </summary>
        /// <param name="shujuid"></param>
        /// <param name="shujuleixing"></param>
        /// <returns></returns>
        public An_jiegoushujucunchu GetjiegoushujucunchuByType(string shujuid,string shujuleixing)
        {
            return FreeSql.Select<An_jiegoushujucunchu>().Where(x => x.Shujuid == shujuid && x.Cunchuleixing == shujuleixing).ToOne();
        }

    }
}
